import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import Layout from '@/layout'
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
  {
    path: '/setting',
    component: Layout,
    name: 'Setting',
    redirect: '/setting/base',
    meta: {
      title: '参数设置',
      icon: 'setting'
    },
    children: [
      {
        path: 'base',
        name: 'base',
        component: () => import('@/views/setting/base/index'),
        meta: { title: '基础设置', icon: 'setting-base' }
      },
      {
        hidden: true,
        path: 'send-access',
        name: 'send-access',
        component: () => import('@/views/setting/send-access/index'),
        meta: { title: '可发红包用户', icon: 'setting-base' }
      },
      {
        path: 'wechat',
        name: 'Wechat',
        component: () => import('@/views/setting/wechat/index'),
        meta: { title: '公众号设置', icon: 'setting-wechat' }
      },
      {
        path: 'staff',
        name: 'Staff',
        component: () => import('@/views/setting/staff'),
        meta: { title: '员工管理', icon: 'staff' }
      },
      {
        path: 'message',
        name: 'Message',
        component: () => import('@/views/setting/message'),
        meta: { title: '消息设置', icon: 'setting-message' }
      },
      {
        path: 'setting-media',
        name: 'SettingMedia',
        component: () => import('@/views/setting/media'),
        meta: { title: '素材库设置', icon: 'setting-media' }
      },
      {
        path: 'finance',
        name: 'Finance',
        component: () => import('@/views/setting/finance'),
        meta: { title: '财务设置', icon: 'setting-finance' }
      }
    ]
  },
  {
    path: '/entry',
    name: 'Entry',
    component: Layout,
    children: [{
      path: 'entry',
      name: 'entry',
      component: () => import('@/views/entry'),
      meta: { title: '应用入口', icon: 'entry' }
    }]
  },
  {
    path: '/member',
    name: 'Member',
    component: Layout,
    children: [{
      path: 'member',
      name: 'member',
      component: () => import('@/views/member'),
      meta: { title: '用户列表', icon: 'member' }
    }]
  },
  {
    path: '/red',
    name: 'Red',
    component: Layout,
    children: [{
      path: 'red',
      name: 'red',
      component: () => import('@/views/red'),
      meta: { title: '红包列表', icon: 'red' }
    }]
  },
  {
    path: '/media',
    name: 'Media',
    component: Layout,
    children: [{
      path: 'media',
      name: 'media',
      component: () => import('@/views/media'),
      meta: { title: '素材审核', icon: 'media' }
    }]
  },
  {
    path: '/coupon',
    name: 'Coupon',
    component: Layout,
    children: [{
      path: 'coupon',
      name: 'coupon',
      component: () => import('@/views/coupon'),
      meta: { title: '卡券审核', icon: 'coupon' }
    }]
  },
  {
    path: '/deposit',
    name: 'Deposit',
    component: Layout,
    children: [{
      path: 'deposit',
      name: 'deposit',
      component: () => import('@/views/deposit'),
      meta: { title: '提现列表', icon: 'deposit' }
    }]
  },
  {
    path: '/edit-account',
    component: Layout,
    redirect: '/edit-account/index',
    hidden: true,
    children: [{
      path: 'index',
      name: 'EditAccount',
      meta: { title: '修改账号' },
      component: () => import('@/views/edit-account/index')
    }]
  },
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
